package org.concepts.algorithm.datastructure;

import static org.junit.Assert.*;
import org.junit.Test;

public class TestSimpleNode {

  /**
   * Ensures that we are able to create a root node.
   */
  @Test
  public void testCreatingRoot() {
    SimpleNode<Integer> root = new SimpleNode<Integer>(1);
    System.out.println("Root node " + root);
    
    assertNotNull(root.getId());
    assertEquals(1, root.getValue().intValue());
    assertNull(root.getParent());
    assertNotNull(root.getChildren());
    assertEquals(0, root.getChildren().size());
  }

  /**
   * Ensure that we are able to create a node and then add children to it.
   */
  /**
   * 
   */
  @Test
  public void testAddingChildren() {
    SimpleNode<Integer> root = new SimpleNode<Integer>(1);
    System.out.println("Root node " + root);
    SimpleNode<Integer> firstChild = new SimpleNode<Integer>(2);
    SimpleNode<Integer> secondChild = new SimpleNode<Integer>(3);
    root.addChild(firstChild);
    root.addChild(secondChild);
    System.out.println("first child: " + firstChild);
    System.out.println("Second child: " + secondChild);
    
    assertEquals(2, root.getChildren().size());
    assertSame(firstChild, root.getChildren().get(0));
    assertSame(secondChild, root.getChildren().get(1));
    assertSame(root, root.getChildren().get(0).getParent());
    assertSame(root, root.getChildren().get(1).getParent());
    
  }

}
